<template>
  <div class="pie-echart">
    <BaseEchart :options="options" />
  </div>
</template>

<script lang="ts" setup>
import { defineProps, computed, PropType } from 'vue'
import type { ComputedRef } from 'vue'
import BaseEchart from '@/base-ui/echart'
import type { EChartsOption } from 'echarts'

interface IRoseData {
  value: number
  name: string
}

const props = defineProps({
  roseData: {
    type: Array as PropType<IRoseData[]>,
    required: true
  }
})

const options: ComputedRef<EChartsOption> = computed(() => {
  return {
    legend: {
      top: 'bottom'
    },
    toolbox: {
      show: true,
      feature: {
        mark: { show: true },
        dataView: { show: true, readOnly: false },
        restore: { show: true },
        saveAsImage: { show: true }
      }
    },
    series: [
      {
        name: '类别数据',
        type: 'pie',
        radius: [10, 110],
        center: ['50%', '50%'],
        roseType: 'area',
        itemStyle: {
          borderRadius: 8
        },
        data: props.roseData
      }
    ]
  }
})
</script>

<style lang="less" scoped></style>
